package unionpay

import (
	"errors"
)

var b2bCache = map[string]*B2bClient{}

func SetB2bClient(key string, conf *B2bConfig) error {
	var (
		ac  *B2bClient
		err error
	)
	if b2bCache[key] != nil {
		return errors.New("key existed")
	}
	ac, err = NewB2bClient(conf)
	if err != nil {
		return err
	}
	b2bCache[key] = ac
	return nil
}

func GetB2bClient(key string) *B2bClient {
	return b2bCache[key]
}
